package com.quantdo.qtm.mysql.service.monitor.impl.rule;

import java.util.Objects;

import org.springframework.stereotype.Service;

import com.quantdo.qtm.mysql.pojo.model.MysqlStatusCurrDo;
import com.quantdo.qtm.mysql.pojo.model.MysqlStatusPointDo;
import com.quantdo.qtm.mysql.service.monitor.SingleUpdateOpareService;

/**
 * 发送量
 * @author USER
 *
 */
@Service
public class SentFluxService implements SingleUpdateOpareService{

    @Override
    public void updateOpare(MysqlStatusCurrDo statusCurrNewDo, MysqlStatusCurrDo statusCurrOldDo, MysqlStatusPointDo pointDo) {
        if (Objects.isNull(statusCurrOldDo) || Objects.isNull(statusCurrOldDo.getBytesSent())) {
            pointDo.setBytesSent(0);
        } else {
            pointDo.setBytesSent(statusCurrNewDo.getBytesSent()-statusCurrOldDo.getBytesSent());
        }
    }
}
